package com.qubuyer.customview;

import android.graphics.Rect;
import android.view.View;

import com.blankj.utilcode.util.ConvertUtils;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class GoodItemDecoration extends  RecyclerView.ItemDecoration {
    private int dp2 = ConvertUtils.dp2px(2f);
    private int dp4 = ConvertUtils.dp2px(4f);
    private int dp8 = ConvertUtils.dp2px(8f);
    private int dp10 = ConvertUtils.dp2px(10f);
    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
        int adapterPosition = parent.getChildAdapterPosition(view);
        if ((adapterPosition) % 2 == 0) {
            outRect.set(dp10, dp8, dp4, 0);
            return;
        }
        if ((adapterPosition) % 2 == 1) {
            outRect.set(dp4, dp8, dp10, 0);
            return;
        }
//        if (parent.getChildAdapterPosition(view) % 2 != 0) {
//            outRect.set(ConvertUtils.dp2px(2.5f), ConvertUtils.dp2px(5), 0, 0);
//        } else if (parent.getChildAdapterPosition(view) % 2 == 0) {
//            outRect.set(0, ConvertUtils.dp2px(5), ConvertUtils.dp2px(2.5f), 0);
//        }
    }
}
